//
//  MainViewController.m
//  小慕餐厅
//
//  Created by Mac on 2018/1/1.
//  Copyright © 2018年 Mac. All rights reserved.
//

#import "MainViewController.h"
#import "HomeViewController.h"
#import "FindViewController.h"
//#import "OrderViewController.h"
#import "UserViewController.h"
#import "Util.h"

//#import "../xtedu-Swift.h"
#import "AudioRecorderAndUpload-Swift.h"

#import "../cate/speechTVC.h"
#import "../cate/cateTVC2.h"
#import "../Utils/DataPersist.h"
#import "HomeVC1.h"

@interface MainViewController (){
    HomeVC1 *vc_home; //HomeViewController
    FindViewController *vc_find;
    UserViewController *vc_user;
//    OrderViewController *vc_order;
    
    
    cateTVC2 *catetvc2;
    
    speechTVC *speechtvc;
    
    ReportTVC *revc;
    
    UINavigationController *nav_home;
    UINavigationController *nav_find;
    UINavigationController *nav_user;
    UINavigationController *nav_order;
    
    UINavigationController *nav_cate;
    UINavigationController *nav_speech;
    UINavigationController *nav_revc;
}

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    vc_home = [[HomeVC1 alloc]init];
    vc_home.tabBarItem.title = @"主页";
    vc_home.tabBarItem.image = [UIImage imageNamed:@"home.png"];
    nav_home = [[UINavigationController alloc]initWithRootViewController:vc_home];
    [self addChildViewController:nav_home];
    
   
    catetvc2 = [[cateTVC2 alloc]init];
    catetvc2.tabBarItem.title = @"听力作业";
    catetvc2.title = @"听力作业";
    catetvc2.postcate =  4;
    catetvc2.tabBarItem.image = [UIImage imageNamed:@"shop.png"]; //find.png
    nav_speech = [[UINavigationController alloc]initWithRootViewController:catetvc2];
    [self addChildViewController:nav_speech];
    
    // 单独语音作业
    speechtvc = [[speechTVC alloc]init];
    speechtvc.tabBarItem.title =  @"语音作业";
    speechtvc.postcate =  9;
    speechtvc.tabBarItem.image = [UIImage imageNamed:@"shop.png"]; //find.png
    nav_find = [[UINavigationController alloc]initWithRootViewController:speechtvc];
    [self addChildViewController:nav_find];
    //
    
    revc = [[ReportTVC alloc]init];
    revc.tabBarItem.title = @"课堂报告";
    [DataPersist writeValuePre:@"10" key:@"postcate"];

    revc.tabBarItem.image = [UIImage imageNamed:@"shop.png"];
    nav_revc = [[UINavigationController alloc]initWithRootViewController:revc];
    [self addChildViewController:nav_revc];
    

    vc_user = [[UserViewController alloc]init];
    vc_user.tabBarItem.title = @"用户";
    vc_user.tabBarItem.image = [UIImage imageNamed:@"user.png"];
    nav_user = [[UINavigationController alloc]initWithRootViewController:vc_user];
    [self addChildViewController:nav_user];
    
   
    
    self.tabBar.tintColor = MYCOLORBLUE;
    self.view.backgroundColor = [UIColor whiteColor];
    
//    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orderItem:) name:@"imoocorder" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(returnfind) name:@"returnfindvc" object:nil];
    
}
-(void)returnfind{
    self.selectedIndex = 1;
}
//-(void)orderItem:(NSNotification*)notif{
//    NSDictionary *dic = notif.userInfo;
//    NSString *orderNum = [dic valueForKey:@"orderNum"];
//    vc_order.tabBarItem.badgeValue = orderNum;
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
